home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / MOVE_TXT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  3KB  |  112 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 385 of 394                                                               
  3. From : Michael Nicolai                     2:2401/411.2         02 Jul 93  13:56 
  4. To   : All                                 3:640/523.62                          
  5. Subj : FAQ: Moving text in textmode                                           
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hi folks...hello everybody......
  8.  
  9. In the last couple of weeks i often read something like this:
  10.  
  11.  "How can i move text around the screen WITHOUT distortions??? Oh, and it
  12.   only has to work in textmode."
  13.  
  14. So, i took some minutes off and wrote a little program to illustrate how
  15. easy this task can be. :-)
  16.  
  17. I used Turbo-Pascal 6.0 but the program can be easily adopted to any Pascal
  18. compiler (and to different machines as the PC).
  19.  
  20. If the text moves too fast or too slow on your screen, change the
  21. "delay(40)"-command to an appropriate value.
  22.  
  23. If you do have any questions, feel free to write.
  24. BTW, i must tell you there are some BIG troubles according the FIDO-Net
  25. over here in germany. So, PLEASE, don't be upset if i don't answer. Just
  26. re-post your message again and again and.... :-)))))))))
  27.  
  28. Ok, here is the code:
  29.  
  30. -----snip-----------------------------------------------------------------}
  31.  
  32. program move_txt;
  33.  
  34. uses CRT;
  35.  
  36. const
  37.  
  38.  text  : string = ' Michael Nicolai ';
  39.  clear : string = '                 ';
  40.  Move1 : string = 'LLLLLLLLLLLLLLLDDDDDDDD';
  41.  Move2 : string = 'RRRRRRRRRRRRRRRUUUUUUU';
  42.  Move3 : string = 'RRRUULLLLLLLLLLLDDDDDDLLLLLLL';
  43.  Move4 : string = 'DDDDDRRRRRRRRRRRRRUUUUUUUUUU';
  44.  Move5 : string = 'LLLLLLLLLLLLLLLLLUUUUUU';
  45.  Move6 : string = 'RRRRRRRRRRRRDDDDDDRRRRRRRRRRRRRR';
  46.  Move7 : string = 'RRRRRRRLLLLLLLLLLLLL';
  47.  
  48. var
  49.  
  50.  x, y   : byte;
  51.  margin : byte;
  52.  Move   : string;
  53.  i      : integer;
  54.  
  55. procedure MoveDown;
  56. begin
  57.  if (y < 25) then
  58.  begin
  59.   gotoxy(x, (y + 1));
  60.   write(text);
  61.   gotoxy(x, y);
  62.   write(clear);
  63.   y := y + 1;
  64.  end;
  65. end;
  66.  
  67. procedure MoveUp;
  68. begin
  69.  if (y > 1) then
  70.  begin
  71.   gotoxy(x, (y - 1));
  72.   write(text);
  73.   gotoxy(x, y);
  74.   write(clear);
  75.   y := y - 1;
  76.  end;
  77. end;
  78.  
  79. begin
  80.  x := 32;
  81.  y := 12;
  82.  margin := 80 - ord(text[0]);
  83.  Move := Move1 + Move2 + Move3 + Move4 + Move5 + Move6 + Move7;
  84.  clrscr;
  85.  gotoxy(x, y);
  86.  write(text);
  87.  
  88.  repeat
  89.   for i := 1 to ord(Move[0]) do
  90.   begin
  91.    case Move[i] of
  92.  
  93.     'L' : begin
  94.     if (x > 1) then
  95.      x := x - 1;
  96.      gotoxy(x, y);
  97.      write(text);
  98.    end;
  99.     'R' : begin
  100.     if (x < margin) then
  101.      x := x + 1;
  102.      gotoxy(x, y);
  103.      write(text);
  104.    end;
  105.     'D' : MoveDown;
  106.     'U' : MoveUp;
  107.  
  108.    end;
  109.    delay(40);
  110.   end;
  111.  until keypressed;
  112. end.